package com.example.pcl.controller.user;


import com.example.pcl.constant.MessageConstants;
import com.example.pcl.pojo.dto.KnowledgeQueryDto;
import com.example.pcl.result.Result;
import com.example.pcl.service.IMentalHealthKnowledgeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 心理健康知识表，存储与心理健康相关的知识内容 前端控制器
 * </p>
 *
 * @author xx
 * @since 2024-12-17
 */
@RestController("userMentalHealthKnowledgeController")
@RequestMapping("/user/mhk")
@Slf4j
@RequiredArgsConstructor
@Tag(name = "用户端心理健康知识相关接口")
public class MentalHealthKnowledgeController {

    private final IMentalHealthKnowledgeService knowledgeService;




    /**
     * 分页查询
     *
     * @param queryDto dto
     * @return 分页列表
     */
    @GetMapping("/list")
    @Operation(summary = "查询心理健康知识列表")
    public Result<?> listKnowledge(KnowledgeQueryDto queryDto) {
        log.info("用户分页查询心理健康知识列表：{}", queryDto);
        return Result.success(knowledgeService.listKnowledge(queryDto), MessageConstants.SELECT_OK);
    }

    /**
     * 查询知识详情
     *
     * @param id 知识 ID
     * @return 知识详情
     */
    @GetMapping("/detail/{id}")
    @Operation(summary = "查询心理健康知识详情")
    public Result<?> getKnowledgeById(@PathVariable Integer id) {
        log.info("用户获取心理健康知识详细:{}", id);
        return Result.success(knowledgeService.getById(id), MessageConstants.SELECT_OK);
    }
}
